import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
	  user:localStorage.user==null ? {} : JSON.parse(localStorage.user),
	  userDetail:null,
	  permission:localStorage.permission==null ? [] : JSON.parse(localStorage.permission),
  },
  mutations: {
	  setUser:function(state,user){
	  	localStorage.setItem("user",JSON.stringify(user))
	  	state.user=Object.assign({},user)
	  },
	  
	  setUserDetail:function(state,userDetail){
	  	state.userDetail=Object.assign({},userDetail)
	  },
	  
	  setPermission:function(state,permission){
	  	localStorage.setItem("permission",JSON.stringify(permission))
	  	state.permission=permission
	  },
  },
  actions: {
	  
  },
  modules: {
	  
  }
})
